package com.zyh.day03

object StudentTest {
  def main(args: Array[String]): Unit = {
    val s1: Student = Student("xiaohei", 18, 100)
    val s2: Student = Student("xiaohei", 18, 100)
    val s3: Student = Student("xiaohei", 18, 100)

    maxStudent(s1,s2,(s1:Student,s2:Student) => s1.age - s2.age )
    maxStudent(s1,s2,(s1,s2) => (s1.score - s2.score).toInt)
  }
  def maxStudent(s1:Student,s2:Student,compare:(Student,Student)=>Int): Student = {
    if(compare(s1,s2) > 0) s1 else s2
  }
}
case class Student(name:String,age:Int,score:Double){
  override def toString: String = s"$name,$age,$score"
}
